<template>
  <el-container class="main_con" style="padding:0;">
   <div class="filter_con ds_block nopt">
      <div class="filter_area">
        <date-picker @change="gettime" size="medium" class="mr_15 mt_15"></date-picker>
        <el-button @click="searchData" size="medium">搜索</el-button>
      </div>
    </div>
    <div class="list_con" style="margin-top:0;">
      <el-table  :data="list" fit highlight-current-row>
        <el-table-column prop="create_time" label="获得日期"></el-table-column>
        <el-table-column prop="integral" label="余额变化"></el-table-column>
        <el-table-column prop="type_text" label="备注"></el-table-column>
      </el-table>
      <div class="table_footer" style="display:flex;justify-content:flex-end;">
        <el-pagination @current-change="ChangeCurrent" hide-on-single-page class="pages" background layout="prev, pager, next" :total="total">
        </el-pagination>
      </div>
    </div>
  </el-container>
</template>

<script>
import DatePicker from '@/components/DatePicker/index'
import {
  userScoreList
} from '@/api/mall/user';
export default {
  name:'scoreList',
  data() {
    return {
      isLoading:false,
      list:[],
      obj:{
        user_id:'',
        //type:'',
        begin_date:'',
        end_date:'',
      },
      page:1,
      size:5,
      objTemp:{},
      total:0
    }
  },
  components: {
    DatePicker
  },
  methods: {
    //初始化
    init(id){
      this.obj.user_id = id;
      this.searchData();
    },
    //搜索数据
    searchData(){
      this.objTemp = {...this.obj};
      this.getData();
    },
    //搜索函数
    getData(){
      this.isLoading = true;
      userScoreList(this.objTemp,this.page,this.size).then(res => {
        this.isLoading = false;
        this.list = res.msg.data;
        this.total = res.msg.total;
      }).catch(e => {
        this.isLoading = false;
      })
    },
    //获取时间
    gettime(value) {
      this.obj.begin_date = value[0];
      this.obj.end_date = value[1]
    },
    //切换页码
    ChangeCurrent(page) {
      this.obj.page = page;
      this.getData()
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
